package com.meishij.fragment.malldetailfragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.meishij.R;
import com.meishij.adapter.MallFragmentAdapter;
import com.meishij.entry.MallSellEntry;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class MallMessageFragment extends Fragment {


    private View view;
    private TabLayout mall_message_tab;
    private List<String> tabTitle=new ArrayList<>();
    private List<Fragment> fragmentList=new ArrayList<>();
    private MallMessageConsultFragment mallMessageConsultFragment;
    private MallMessageOrderFragment mallMessageOrderFragment;
    private MallFragmentAdapter mallFragmentAdapter;
    private ViewPager mall_message_viewpager;

    public MallMessageFragment() {
        // Required empty public constructor

    }



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        if(view!=null){
            return view;
        }
        view = inflater.inflate(R.layout.fragment_mall_message, container, false);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        Bundle arguments = getArguments();
        MallSellEntry.ObjBean data = (MallSellEntry.ObjBean) arguments.getSerializable("data");
        mall_message_tab = ((TabLayout) view.findViewById(R.id.mall_message_tab));
        mall_message_viewpager = ((ViewPager) view.findViewById(R.id.mall_message_viewpager));
        tabTitle.add("买家晒单");
        tabTitle.add("买家咨询");
        Bundle bundle=new Bundle();
        bundle.putSerializable("data",data);
        mallMessageConsultFragment = new MallMessageConsultFragment();
        mallMessageConsultFragment.setArguments(bundle);
        mallMessageOrderFragment = new MallMessageOrderFragment();
        mallMessageOrderFragment.setArguments(bundle);
        fragmentList.add(mallMessageOrderFragment);
        fragmentList.add(mallMessageConsultFragment);
        mallFragmentAdapter = new MallFragmentAdapter(getChildFragmentManager(),tabTitle,fragmentList);
        mall_message_viewpager.setAdapter(mallFragmentAdapter);
        mall_message_tab.setupWithViewPager(mall_message_viewpager);
    }
}
